package main

import (
	"bufio"
	"fmt"
	"net"
	"os"
	"time"
)

var inputRead *bufio.Reader
var erro error

func main() {
	fmt.Println("Hello, Go!")
	conn, err := net.Dial("tcp", "www.baidu.com:80")
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer conn.Close()

	fmt.Println("成功")

	now := time.Now()
	fmt.Println("现在时间:", now)

	file, err := os.OpenFile("main/test.txt", os.O_RDWR, 666)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}

	fmt.Println("已经打开文件")

	writeString, err := file.WriteString("o1111111111111111111kok!!!!")
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("成功写入,字符串长度为%d:", writeString)
	file.Close()

	inputRead = bufio.NewReader(os.Stdin)
	input, err := inputRead.ReadString('\n')
	if err != nil {
		fmt.Println("error")

	}
	fmt.Println(input)
}
